#pragma once
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include "Scrambler.h"
#include "Rescrambler.h"

using namespace std;

void main()
{
	char b;
	bool bit;
	vector <bool> data, outdata, data2;
	cin >> b;
	while ((b == '0') || (b == '1'))
	{
		bit = int(b) - 48;
		//cout << bit << " - bit" << endl;
		data.push_back(bit);
		cin >> b;
	}
	cout << "Ok." << endl;

	Scrambler < vector<bool> > * scr = new Scrambler< vector<bool> >(5);

	scr->ScrambleData(data, outdata );

	cout << endl;
	cout << "Scrambled data:" << endl;
	cout << endl;

	int i;
	for (i = 0; i < outdata.size(); i++)
	{
		if ((i+1) % 8 == 0)
		{
			cout << outdata[i] << endl;
		}
		else
		{
			cout << outdata[i] << ' ';
		}
	}

	cout << endl;
	cout << endl;
	cout << "Extra data:" << outdata.size()-data.size() << "bit" << endl;
	cout << endl;

	Rescrambler < vector<bool> > * rscr = new Rescrambler< vector<bool> >(5);
	rscr->RescrambleData(outdata, data2);
	for(i = 0; i < data2.size() ; i++)
	{
		if ((i + 1) % 8 == 0)
		{
			cout << data2[i] << endl;
		}
		else
		{
			cout << data2[i] << ' ';
		}
	}

	cout << endl;
	cout << endl;

	//sort(data.begin(), data.end());
	//sort(data2.begin(), data2.end());
	//if (  set_difference(data.begin(), data.end(), data2.begin(), data2.end()),  data2.begin() )
	if (equal(data.begin(), data.end(), data2.begin()))
	{
		cout << "Data has been transmitted successfully." << endl;
	}
}